﻿USE [SyncSamplesDb_ChangeTracking_Custom]
		
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS, NOCOUNT ON
GO
SET DATEFORMAT YMD
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
-- Pointer used for text / image updates. This might not be needed, but is declared here just in case
DECLARE @pv binary(16)
BEGIN TRANSACTION

-- Drop constraints from [Sales].[OrderHeader]
ALTER TABLE [Sales].[OrderHeader] DROP CONSTRAINT [FK_OrderHeader_Customer]

-- Drop constraints from [Sales].[OrderDetail]
ALTER TABLE [Sales].[OrderDetail] DROP CONSTRAINT [FK_OrderDetail_OrderHeader]

-- Drop constraints from [Sales].[CustomerContact]
ALTER TABLE [Sales].[CustomerContact] DROP CONSTRAINT [FK_CustomerContact_Customer]

-- Add rows to [Sales].[Customer]
INSERT INTO [Sales].[Customer] ([CustomerId], [CustomerName], [SalesPerson], [CustomerType]) VALUES ('b207dd86-f296-4dfd-b22c-7b94b4ddab4f', N'Rural Cycle Emporium', N'Brenda Diaz', N'Retail')
INSERT INTO [Sales].[Customer] ([CustomerId], [CustomerName], [SalesPerson], [CustomerType]) VALUES ('46f98359-6fae-4966-9c84-9534f373ca5e', N'Sharp Bikes', N'Brenda Diaz', N'Retail')
INSERT INTO [Sales].[Customer] ([CustomerId], [CustomerName], [SalesPerson], [CustomerType]) VALUES ('46a855da-0623-477e-9553-b48cd0b7f9eb', N'Tandem Bicycle Store', N'Brenda Diaz', N'Wholesale')
INSERT INTO [Sales].[Customer] ([CustomerId], [CustomerName], [SalesPerson], [CustomerType]) VALUES ('79d6969c-963a-40bd-ab61-efcbb588e90d', N'Exemplary Cycles', N'James Bailey', N'Retail')
INSERT INTO [Sales].[Customer] ([CustomerId], [CustomerName], [SalesPerson], [CustomerType]) VALUES ('66675142-effa-4069-b56f-fc6c788a16c5', N'Aerobic Exercise Company', N'James Bailey', N'Wholesale')
-- Operation applied to 5 rows out of 5

-- Add rows to [Sales].[CustomerContact]
INSERT INTO [Sales].[CustomerContact] ([CustomerId], [PhoneType], [PhoneNumber]) VALUES ('b207dd86-f296-4dfd-b22c-7b94b4ddab4f', N'Business', N'158-555-0142')
INSERT INTO [Sales].[CustomerContact] ([CustomerId], [PhoneType], [PhoneNumber]) VALUES ('b207dd86-f296-4dfd-b22c-7b94b4ddab4f', N'Mobile', N'453-555-0167')
INSERT INTO [Sales].[CustomerContact] ([CustomerId], [PhoneType], [PhoneNumber]) VALUES ('46a855da-0623-477e-9553-b48cd0b7f9eb', N'Business', N'107-555-0138')
INSERT INTO [Sales].[CustomerContact] ([CustomerId], [PhoneType], [PhoneNumber]) VALUES ('79d6969c-963a-40bd-ab61-efcbb588e90d', N'Business', N'959-555-0151')
-- Operation applied to 4 rows out of 4

-- Add rows to [Sales].[OrderDetail]
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (1, '61b9944c-8362-4761-bbd8-68239d7c9ca7', N'Mountain Tire', 7)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (1, 'ac8510ba-bd0e-4716-8fe6-a0d9dbd9deba', N'Chain', 3)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (1, '74bd1ae6-1042-42b3-b57f-aa65f1b68660', N'Mountain Tire', 5)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (1, '00350b2c-1e83-4fe0-a944-be4ca6257586', N'Hydration Pack', 1)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (1, '517021ac-8559-49d4-a174-ce2c9f5ba428', N'Road Pedal', 4)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (2, '74bd1ae6-1042-42b3-b57f-aa65f1b68660', N'Women''s Mountain Shorts', 5)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (2, '00350b2c-1e83-4fe0-a944-be4ca6257586', N'Men''s Sports Shorts', 3)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (2, '517021ac-8559-49d4-a174-ce2c9f5ba428', N'Road Rear Wheel', 4)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (3, '74bd1ae6-1042-42b3-b57f-aa65f1b68660', N'Road Pedal', 2)
INSERT INTO [Sales].[OrderDetail] ([OrderDetailId], [OrderId], [Product], [Quantity]) VALUES (3, '00350b2c-1e83-4fe0-a944-be4ca6257586', N'Water Bottle', 6)
-- Operation applied to 10 rows out of 10

-- Add rows to [Sales].[OrderHeader]
INSERT INTO [Sales].[OrderHeader] ([OrderId], [CustomerId], [OrderDate], [OrderStatus]) VALUES ('61b9944c-8362-4761-bbd8-68239d7c9ca7', '79d6969c-963a-40bd-ab61-efcbb588e90d', '2007-02-03 00:00:00.000', N'Pending')
INSERT INTO [Sales].[OrderHeader] ([OrderId], [CustomerId], [OrderDate], [OrderStatus]) VALUES ('ac8510ba-bd0e-4716-8fe6-a0d9dbd9deba', '79d6969c-963a-40bd-ab61-efcbb588e90d', '2007-01-28 00:00:00.000', N'Complete')
INSERT INTO [Sales].[OrderHeader] ([OrderId], [CustomerId], [OrderDate], [OrderStatus]) VALUES ('74bd1ae6-1042-42b3-b57f-aa65f1b68660', 'b207dd86-f296-4dfd-b22c-7b94b4ddab4f', '2007-04-14 00:00:00.000', N'Back Ordered')
INSERT INTO [Sales].[OrderHeader] ([OrderId], [CustomerId], [OrderDate], [OrderStatus]) VALUES ('00350b2c-1e83-4fe0-a944-be4ca6257586', 'b207dd86-f296-4dfd-b22c-7b94b4ddab4f', '2007-03-12 00:00:00.000', N'Complete')
INSERT INTO [Sales].[OrderHeader] ([OrderId], [CustomerId], [OrderDate], [OrderStatus]) VALUES ('517021ac-8559-49d4-a174-ce2c9f5ba428', '46a855da-0623-477e-9553-b48cd0b7f9eb', '2007-02-04 00:00:00.000', N'Complete')
-- Operation applied to 5 rows out of 5

-- Add rows to [Sales].[Vendor]
INSERT INTO [Sales].[Vendor] ([VendorId], [VendorName], [CreditRating], [PreferredVendor]) VALUES ('6df98f6e-d47b-40be-8f20-0a5588f09317', N'Compete, Inc.', 5, 0)
INSERT INTO [Sales].[Vendor] ([VendorId], [VendorName], [CreditRating], [PreferredVendor]) VALUES ('78dc5bfc-4ee5-4451-a9cf-23681007909f', N'Green Lake Bike Company', 2, 1)
INSERT INTO [Sales].[Vendor] ([VendorId], [VendorName], [CreditRating], [PreferredVendor]) VALUES ('2012b7f6-9ae3-4b1e-8325-65ea82d07dd1', N'Premier Sport, Inc.', 2, 1)
INSERT INTO [Sales].[Vendor] ([VendorId], [VendorName], [CreditRating], [PreferredVendor]) VALUES ('580c4a03-47cc-4e71-8f36-6f140bdd6c68', N'Metro Sport Equipment', 1, 1)
INSERT INTO [Sales].[Vendor] ([VendorId], [VendorName], [CreditRating], [PreferredVendor]) VALUES ('4961c8f1-1ea0-4336-a695-90fe3710b3f4', N'Mountain Works', 3, 0)
-- Operation applied to 5 rows out of 5

-- Add constraints to [Sales].[OrderHeader]
ALTER TABLE [Sales].[OrderHeader] ADD CONSTRAINT [FK_OrderHeader_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [Sales].[Customer] ([CustomerId])

-- Add constraints to [Sales].[OrderDetail]
ALTER TABLE [Sales].[OrderDetail] ADD CONSTRAINT [FK_OrderDetail_OrderHeader] FOREIGN KEY ([OrderId]) REFERENCES [Sales].[OrderHeader] ([OrderId])

-- Add constraints to [Sales].[CustomerContact]
ALTER TABLE [Sales].[CustomerContact] ADD CONSTRAINT [FK_CustomerContact_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [Sales].[Customer] ([CustomerId])
COMMIT TRANSACTION
GO